﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 9/1/2009
 * Time: 2:28 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using NHibernate;
using System.Collections.Generic;
using System.Data;
using Buaya.Model.Dao.Interface;

namespace Buaya.Model.Dao.NHibernate
{
	/// <summary>
	/// Description of NHibernateLoanTypeDao.
	/// </summary>
	public class NHibernateLoanTypeDao : ILoanTypeDao
	{
		public NHibernateLoanTypeDao()
		{
		}
		
		public void SaveOrUpdate(LoanType type)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.SaveOrUpdate(type);
			session.Flush();
		}
		
		public void Delete(LoanType type)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.Delete(type);
			session.Flush();
		}
		
		public LoanType ReadByPk(int id)
		{
			return NHibernateHelper.OpenSession().Load<LoanType>(id);
		}
		
		public IList<LoanType> FindAll()
		{
			return NHibernateHelper.OpenSession().CreateCriteria(typeof(LoanType)).List<LoanType>();
		}
	}
}
